import 'package:flutter/material.dart';
import 'package:news_demo/Pojo/News_Itme_Pojo.dart';
import 'package:news_demo/View/Intercalate/Intercalate.dart';
import 'package:news_demo/View/NewValue/NewValue.dart';

class NewsItme extends StatelessWidget {
  final NewsItmePojo NIP;
  const NewsItme({Key? key,required this.NIP}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.fromLTRB(4.0, 10, 4.0, 0),
      decoration: BoxDecoration(
        border: Border.all(
          color: Colors.black26,
          width: 1.0,
        ),
        borderRadius: BorderRadius.all(Radius.circular(4)),
      ),
      height: 102,
      width: double.infinity,
      child: GestureDetector(
        onTap: (){
          Navigator.push(context, MaterialPageRoute(builder: (context)=>NewValue(NewKey: NIP.newsKey,)));
        },
        child: Column(
          children: [
            Container(
              child: Row(
                children: [
                  // 图片
                  Expanded(
                    flex: 3,
                    child: Container(
                      padding: const EdgeInsets.all(4),
                      height: 100,
                      child: Image.network(
                        NIP.imageUrl,
                        fit: BoxFit.fill,
                      ),
                    ),
                  ),
                  //文字
                  Expanded(
                    flex: 7,
                    child: Container(
                      height: 100,
                      width: double.infinity,
                      child: Column(
                        children: [
                          //标题
                          Expanded(
                            flex: 7,
                            child: Container(
                              padding: const EdgeInsets.all(4),
                              width: double.infinity,
                              //标题
                              child: Text(
                                NIP.titleValue,
                                style: TextStyle(
                                    fontWeight: FontWeight.w600,
                                    fontSize: 14
                                ),
                              ),
                            ),
                          ),
                          //注释
                          Expanded(
                              flex: 3,
                              child: Container(
                                padding: const EdgeInsets.all(4),
                                width: double.infinity,
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  children: [
                                    //提供方的信息
                                    Container(
                                      alignment: Alignment.center,
                                      height: double.infinity,
                                      //绑定部门
                                      child: Text(NIP.department,
                                        style: TextStyle(
                                            fontSize: 14
                                        ),),
                                    ),
                                    //  日期
                                    Container(
                                      alignment: Alignment.center,
                                      height: double.infinity,
                                      margin: const EdgeInsets.fromLTRB(0, 0, 10, 0),
                                      //绑定时间
                                      child: Text(NIP.timeValue,
                                        style: TextStyle(
                                            fontSize: 14
                                        ),
                                      ),
                                    ),
                                  ],
                                ),
                                // height: ,
                              )
                          ),
                        ],
                      ),
                    ),
                  )
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
